//
//  ThirdViewController.m
//  UINavigationDemo
//
//  Created by shk on 14/11/12.
//  Copyright (c) 2014年 com.shk. All rights reserved.
//

#import "ThirdViewController.h"

@interface ThirdViewController ()

@end

@implementation ThirdViewController




- (void) loadView{
    UIView *baseView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    baseView.backgroundColor = [UIColor greenColor];
    self.view = baseView;
    
    UIButton *push = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [push setTitle:@"push" forState:UIControlStateNormal];
    [push setFrame:CGRectMake(90, 100, 150, 35)];
    [push addTarget:self action:@selector(pushVC) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:push];
    
    UIButton *pop = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [pop setTitle:@"pop" forState:UIControlStateNormal];
    [pop setFrame:CGRectMake(90, 150, 150, 35)];
    [pop addTarget:self action:@selector(popVC) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pop];
    
    UIButton *root = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [root setTitle:@"root" forState:UIControlStateNormal];
    [root setFrame:CGRectMake(90, 200, 150, 35)];
    [root addTarget:self action:@selector(rootVC) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:root];
    
    UIButton *index = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [index setTitle:@"index" forState:UIControlStateNormal];
    [index setFrame:CGRectMake(90, 250, 150, 35)];
    [index addTarget:self action:@selector(indexVC) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:index];
    
    
}



- (void) pushVC{
    ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
    [self.navigationController pushViewController:thirdVC animated:YES];
}

- (void) popVC{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void) rootVC{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void) indexVC{
    UIViewController *secondVC = [[self.navigationController viewControllers] objectAtIndex:1];
    [self.navigationController popToViewController:secondVC animated:YES];
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
